$(function () {
    // alert('asd')

    $('.changeBtn').click(function () {
        // alert('111');

        // 获取当前用户id
        let userid = sessionStorage.getItem('id');
        // 获取用户输入信息
        let nickname = $('.newNickname').val();
        let email = $('.newEmail').val();
        // console.log(userid);
        // console.log(nickname);
        // console.log(email);

        if (userid == null) {
            alert('没有ID!')
        } else {
            $.ajax({
                url: 'http://139.9.177.51:3333/p2p/updateuser',
                type:'POST',
                data: {
                    userid,
                    nickname,
                    email
                },
                success: function (res) {
                    // console.log(res);

                    if (res.code == 200) {
                        alert('修改成功!')
                        localStorage.setItem('data', nickname);
                        // $('.login a').html(nickname);
                        location.href = '#personal/info';
                        // location.href = '/';
                    } else {
                        alert('修改失败!')
                    }
                }
            })
        }
    })


})